<?php

require_once 'db.php';

class Keywords extends DB {

    public function select() {
        $this->getConnection();
        $query = "SELECT * FROM keywords WHERE LENGTH(name) > 10";
        $keywords = $this->query($query);
        return $keywords;
    }
    
    
    
    
    
    
    
    
    
    
    
  public function dfsdf(){
       $baitren_mottrang = 10;

                if (!isset($_GET['page'])) {
                    $page = 0;
                } else {
                    $page = (int) $_GET['page'];
                }
                $sodu_lieu = mysql_num_rows(mysql_query("SELECT * FROM works ")) or die(mysql_error());
                $max = 93;
                
                
                $pagenetion= "<a href='index.php?page=$page'></a>";
                
                $counter =0;
                while ($counter <=10){
                   if ($page +$counter >=$max)
                   $pagenetion = "<a href='index.php?page=$page+1'></a>";
                   if ($page - $counter >=0)
                          $pagenetion = "<a href='index.php?page=$page-1'></a>";
                           

                 $counter++;
                }
             
                $huuha = $page * $baitren_mottrang;
                $result = mysql_query("SELECT * FROM works LIMIT {$huuha},{$baitren_mottrang} ") or die(mysql_error());
                $max = $max;
                $div = 5;
?>


<table>
    <tr>
        <td>id</td>
        <td>name</td>
        <td>url</td>
        <td>localtion</td>
        <td>id</td>
         
    </tr>

<?php

                while ($info = mysql_fetch_array($result)) {
                    ?>
    <tr>
                 <td> <?php    echo $info['id'] . " ";?></td>
                  <td> <?php    echo $info['name'] . " ";?></td>
                  <td> <a href='<?php    echo $info['url'] . " ";?>'><?php    echo $info['url'] . " ";?></a></td>
                   <td> <?php    echo $info['posted'] . " ";?></td>
                    <td> <?php    echo $info['location'] . " ";?></td>
                  
    </tr>
    <?php 
                }

//                echo "<a href='index.php?page=1'> Last </a>";
                for ($page = 1; $page <= $max; $page++) {

                echo "<a href='index.php?page={$page}'> {$pagenetion}</a>";
                }
//                echo "<a href='index.php?page={$max}'> Firt </a>";
      
  }
    
    
    
    
    
    
    
    
public function paregation (){
    
    
      $sotrang = 95; 
if(!isset($_GET['page'])) $page = 3; 
else $page = $_GET['page']; 
settype($page, "int"); 
if($page!=1 && $page>2) { 
    echo '<a href="'.$_SERVER['PHP_SELF'].'?page=1">First</a>'; 
    echo ' | '; 
} 
if($page>1) { 
    echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.($page-1).'">Prev</a>'; 
    if($page!=$sotrang) echo ' | '; 
} 
if($page-1>0 && $page+2<$sotrang) { 
    for($i=$page-2; $i<=$page+4; $i++) { 
        if($i!=$page) { 
            echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'">'.$i.'</a>'; 
        } else { 
            echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'" class="active">'.$i.'</a>'; 
        } 
        echo ' | '; 
    } 
} 
if($page<$sotrang) { 
    echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.($page+4).'">Next</a>'; 
    if($page!=$sotrang-1) echo ' | '; 
} 
if($page!=$sotrang && $page<$sotrang-1) { 
    echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$sotrang.'">Last</a>'; 
}  
                
                
                
          
}
    
    
}

?>
</table>